package com.jht.mymvvm.activity.scollview

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView

class ListAdapters(val ctx: Context): RecyclerView.Adapter<ListAdapters.holder>() {

    private val name = listOf(1,2,3,4,5,6,7,89,0,21,1,2,3,4,5,6,7,89,0,21,1,2,3,4,5,6,7,89,0,21,1,2,3,4,5,6,7,89,0,21,1,2,3,4,5,6,7,89,0,21,1,2,3,4,5,6,7,89,0,21)


    inner class holder(itemView: View) :RecyclerView.ViewHolder(itemView) {
          var text:TextView = itemView.findViewById(android.R.id.text1)
    }

    override fun getItemCount(): Int {
      return name.size
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): holder {
        val inflate =
            LayoutInflater.from(ctx).inflate(android.R.layout.simple_list_item_1, parent, false)

        return holder(inflate)
    }

    override fun onBindViewHolder(holder: holder, position: Int) {
        holder.text.text = name[position].toString()
    }

}